//3Sum Closest 
/*
#include <time.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int twoSum(vector<int>&nums,int no,int target){
	int left=0,right=nums.size()-1;
	int re=0,tmp=0;;
	int distance=~(unsigned)0/2;
	while(left<right){
		if(left==no){
			left++;continue;
		}else if(right==no){
			right--;continue;
		}else if(nums[left]+nums[right]==target){
			re=target;break;
		}else if(nums[left]+nums[right]>target){
			tmp=abs(nums[left]+nums[right]-target);
			if(tmp<distance){
				distance=tmp;
				re=nums[left]+nums[right];
			}
			right--;
		}else{
			tmp=abs(nums[left]+nums[right]-target);
				if(tmp<distance){
					distance=tmp;
					re=nums[left]+nums[right];
				}
			left++;
		}
	}
	return re;
}
int threeSumClosest(vector<int>& nums,int target) {
	int distance=~(unsigned) 0/2,min=0;
	int tmp,tmp2;
	sort(nums.begin(),nums.end());
	for(int i=0;i<nums.size();i++){
		tmp=twoSum(nums,i,target-nums[i]);
		tmp2=abs(target-nums[i]-tmp);
		cout<<nums[i]<<","<<tmp<<endl;
		if(tmp2<distance){
			distance=tmp2;
			min=tmp+nums[i];
		}
	}
	return min;
}
int main(){
	string p;
	int a[]={-1,2,1,-4};
	vector<int>v1(a,a+sizeof(a)/sizeof(int));
	int re=threeSumClosest(v1,3);
	cout<<re<<endl;
	system("pause");
	return 0;
}
*/